package com.ssm.lzh.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.lzh.service.BookingService;
import com.ssm.lzh.vo.BookingView;
import com.ssm.pojo.Booking;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("/lzh")
public class BookingController {

    @Resource
    private BookingService bookingService;


    @RequestMapping("/queryAllBooking")
    @ResponseBody
    private PageInfo<BookingView> queryAllBooking(@RequestBody Page<BookingView> page){
        return this.bookingService.queryAllBooking(page);
    }

    @RequestMapping("/confirmBooking")
    @ResponseBody
    public int confirmBooking(@RequestBody Booking booking){

        return     this.bookingService.confirmBooking(booking);
    }


    @RequestMapping("/cancelBooking")
    @ResponseBody
    public int cancelBooking(int rid){
        return     this.bookingService.cancelBooking(rid);
    }

    @RequestMapping("/addBooking")
    @ResponseBody
    public int addBooking(@RequestBody Booking booking){
     return this.bookingService.addBooking(booking);
    }


    public static void main(String[] args) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-M-d");
        System.out.println(dateFormat.format(new Date()).toString());
    }

}
